package com.egu.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.egu.model.Customer;
import com.egu.service.CustomerService;
import com.egu.vo.CustomerVo;
import com.egu.vo.PageParam;
import com.egu.vo.RequestPageVo;
import com.egu.vo.RequestResultVo;

@Controller
@RequestMapping("customerDistr")
public class CustomerDistrController {

	@Autowired
	private CustomerService customerService;

	@RequestMapping("listUI")
	public String listUI() {
		return "customerDistr/listUI";
	}

	//获得用户分配页面数据
	@RequestMapping("/getList")
	@ResponseBody
	public RequestPageVo<CustomerVo> getList(@ModelAttribute(value = "param") PageParam param) {
		RequestPageVo<CustomerVo> vo = customerService.getVoList(param);
		return vo;
	}

	@RequestMapping("/distrCustomer")
	@ResponseBody
	public RequestResultVo<Customer> distrCustomer(Customer customer) {
		RequestResultVo<Customer> result = new RequestResultVo<Customer>();
		if (customer != null) {
			return customerService.saveOrUpdate(customer);
		} else {
			result.setSuccess(false);
		}
		return result;
	}
}
